Skip to main content

Sending Messages to Microsoft Teams with Node-RED

This tutorial shows you how to send inspection notifications from your OV80i camera directly to a Microsoft Teams channel. You'll learn to set up automated alerts that include inspection results and clickable image links, keeping your team instantly informed of production status.

What You'll Build: An automated system that posts OV80i inspection results, including images and pass/fail status, directly into a Microsoft Teams channel.

Real-World Application: Get instant notifications when inspections fail, share inspection images with remote teams, or create automated quality reports in your team collaboration space.

Prerequisites

  • OV80i camera connected to your plant network
  • Microsoft Teams access with permission to add connectors
  • Teams channel where you want to receive notifications
  • Network connectivity between OV80i and Microsoft Teams
  • Basic understanding of Node-RED flows

Tutorial Overview

What we'll build: A Node-RED flow that automatically sends inspection results to Microsoft Teams with clickable image links.

Time required: 15-20 minutes

Skills learned: Teams webhook integration, Node-RED HTTP requests, automated notification systems

Step 1: Set Up Microsoft Teams Webhook

1.1 Access Your Teams Channel

  1. Open Microsoft Teams and navigate to the channel for inspection notifications
  2. Click the three dots (•••) next to the channel name
  3. Select "Manage channel" from the dropdown menu

1.2 Add Incoming Webhook Connector

  1. Click "Connectors" in the channel management menu
  2. Search for "Incoming Webhook" in the connector list
  3. Click "Add" next to the Incoming Webhook option

1.3 Configure Webhook Settings

  1. Name: Enter a descriptive name (e.g., "OV80i Inspection Alerts")
  2. Icon: Optionally upload a custom icon for your notifications
  3. Click "Create" to generate the webhook

1.4 Save Webhook URL

  1. Copy the generated webhook URL - this is crucial for Node-RED setup
  2. Save the URL in a secure location (you'll need it in Step 2)
  3. Click "Done" to complete the Teams setup

Checkpoint: You should now have a webhook URL that looks like: https://yourcompany.webhook.office.com/webhookb2/...

Step 2: Access OV80i Node-RED

2.1 Navigate to Node-RED

  1. Open your OV80i web interface
  2. Go to Recipe Editor > IO Block
  3. Click "Configure I/O" to enter Node-RED editor

2.2 Prepare Your Workspace

  1. Clear an area in the Node-RED canvas for your Teams integration flow
  2. Identify the palette on the left side with available nodes
  3. Plan your flow: Trigger → Process → Send to Teams

Step 3: Build the Node-RED Flow

3.1 Add Required Nodes

Drag these nodes from the palette to your canvas:

  1. Inject node (for testing)
  2. Function node (to format the message)
  3. HTTP request node (to send to Teams)
  4. Debug node (optional, for troubleshooting)

3.2 Connect the Nodes

  1. Wire inject output to function input
  2. Wire function output to HTTP request input
  3. Wire HTTP request output to debug input (optional)

Flow structure:

Inject → Function → HTTP Request → Debug

Step 4: Configure the Function Node

4.1 Basic Message Configuration

  1. Double-click the function node to open configuration
  2. Replace the default code with this basic message format:
// Basic Teams message
msg.headers = {
"Content-Type": "application/json"
};

msg.payload = {
text: "You got a new message from your OV80i"
};

return msg;

For dynamic inspection results with clickable images:

// Dynamic message with inspection image
let imageUrl = msg.payload.image_url;

msg.headers = {
"Content-Type": "application/json"
};

msg.payload = {
text: `Inspection Complete - [View Image](${imageUrl})`
};

return msg;

4.3 Complete Inspection Notification

For full inspection details:

// Complete inspection notification
const inspectionData = msg.payload;
const imageUrl = inspectionData.image_url;
const result = inspectionData.result ? "PASS" : "FAIL";
const timestamp = new Date().toLocaleString();

msg.headers = {
"Content-Type": "application/json"
};

msg.payload = {
text: `🔍 **Inspection ${result}** - ${timestamp}\n\n[View Image](${imageUrl})`
};

return msg;

4.4 Save Function Configuration

  1. Click "Done" to save the function node
  2. Give the node a descriptive name like "Format Teams Message"

Step 5: Configure HTTP Request Node

5.1 Set Up HTTP Request

  1. Double-click the HTTP request node to configure
  2. Set Method: Select "POST" from dropdown
  3. Set URL: Paste your Teams webhook URL from Step 1.4
  4. Set Return: Select "UTF-8 string"

5.2 Additional Settings

  • Name: Enter "Send to Teams" for clarity
  • Headers: Leave empty (handled by function node)
  • Payload: Leave as "Ignore" (handled by function node)

5.3 Save HTTP Configuration

  1. Click "Done" to save the HTTP request node
  2. Verify the webhook URL is correct - this is critical for success

Step 6: Test Your Integration

6.1 Deploy the Flow

  1. Click "Deploy" button in the top-right corner
  2. Wait for "Successfully deployed" confirmation
  3. Check for any error indicators on nodes (red triangles)

6.2 Test with Inject Node

  1. Click the button on the left side of the inject node
  2. Check the debug panel (right sidebar) for any error messages
  3. Verify the message appears in your Teams channel

6.3 Verify Teams Notification

  1. Switch to Microsoft Teams and check your target channel
  2. Look for the test message from your OV80i
  3. Test any clickable links to ensure they work properly

Step 7: Integration with Inspection Flow

7.1 Connect to Inspection Results

To send automatic notifications after each inspection:

  1. Find your main inspection flow (usually starts with "All Block Outputs")
  2. Add your Teams notification as a branch from the main flow
  3. Connect after inspection processing but before final results

7.2 Example Integration Flow

All Block Outputs → [Inspection Logic] → Final Pass/Fail

Format Teams Message → Send to Teams

7.3 Filter Notifications (Optional)

To only send notifications for failed inspections:

// Only send notifications for failures
const inspectionResult = msg.payload.result;

if (!inspectionResult) { // Only if inspection failed
const imageUrl = msg.payload.image_url;

msg.headers = {
"Content-Type": "application/json"
};

msg.payload = {
text: `⚠️ **INSPECTION FAILED** - Immediate attention required\n\n[View Failed Image](${imageUrl})`
};

return msg;
} else {
return null; // Don't send message for passing inspections
}

Step 8: Troubleshooting

8.1 Common Issues

ProblemSymptomsSolution
No message in TeamsDebug shows success but no Teams notificationCheck webhook URL, verify network connectivity
HTTP error 400Bad request error in debugCheck message format, ensure Content-Type header
Image links don't workMessage appears but images won't openVerify image URL is accessible from Teams users' network
Flow doesn't triggerNo debug output when expectedCheck flow connections, verify trigger conditions

8.2 Debug Your Flow

  1. Add debug nodes after each step to trace data flow
  2. Check the debug panel for error messages and data structure
  3. Test with inject node to isolate configuration issues
  4. Verify webhook URL by testing with external tools if needed

8.3 Network Connectivity

  1. Ensure OV80i can reach internet (ping test from camera)
  2. Check firewall settings that might block outbound HTTPS
  3. Verify DNS resolution for Teams webhook URLs
  4. Test from browser on same network as camera

Success! Your Teams Integration is Complete

Your OV80i camera can now:

Send automatic notifications to Microsoft Teams channels

Include clickable image links for immediate inspection review

Filter notifications based on inspection results

Provide rich formatting with inspection details and timestamps

Support multiple channels for different notification types

Best Practices

Message Management

  • Use descriptive channel names for different types of notifications
  • Include timestamps and station identifiers in messages
  • Filter messages to avoid notification overload
  • Test thoroughly before production deployment

Security Considerations

  • Protect webhook URLs - treat them as sensitive credentials
  • Use HTTPS for all communications (default with Teams)
  • Limit network access to necessary services only
  • Regularly rotate webhook URLs if compromised

Performance Optimization

  • Batch notifications if sending many messages
  • Use appropriate retry logic for network failures
  • Monitor message delivery success rates
  • Implement rate limiting to avoid Teams API limits

image.png

Next Steps

After setting up Teams integration:

  1. Create different notification channels for various inspection types
  2. Set up escalation workflows for critical failures
  3. Integrate with other team tools (email, SMS, etc.)
  4. Build dashboards combining Teams with other monitoring tools
  5. Train your team on responding to automated notifications

🔗 See Also